package reflect;

import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo2 {
    public static void main(String[] args) throws Exception {
        Person p = new Person();
        System.out.println(p);
        //Class cls = Class.forName("reflect.Person");
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入方法名：");
        String className = sc.nextLine();
        Class cls = Class.forName(className);
        Object obj = cls.newInstance();
        System.out.println( obj);
    }
}
